package k2_oop.p6_relation.demo03;

//同级类：一个文件中可以有多个同级类，但是只能有一个是public修饰的，被public修饰的这个类的类名必须作为文件名
class A{

}

public class Computer {

    public String brand;
    public double price;

    /**
     * 成员内部类
     *     1.在Computer正常类的内部定义的就是内部类
     *     2.因为是成员内部类，所以在Computer类的范围内都可以使用此类
     */
    public class Mouse{
        public String brand;
        public int size;

        public Mouse(String brand, int size) {
            this.brand = brand;
            this.size = size;
        }

        public void clickContent(String content){
            System.out.println("使用"+this.brand+"品牌的,"+(size>5?"大号":"微型")+"鼠标可以"+content);
        }
    }

    /**
     * static修饰的类叫静态内部类 这个类的整体是属于外部类级别的，与此内部类的内部无关
     */
    public static class KeyBoard{
        public String brand;
        public int keysCount;

        public KeyBoard(String brand, int keysCount) {
            this.brand = brand;
            this.keysCount = keysCount;
        }

        public void inputContext(String content){
            System.out.println(this.brand+"品牌的,"+this.keysCount+"个键子的键盘"+content);
        }
    }


    public void playGame(){

        /**
         * 方法内部类 作用域只能在当前的方法中
         */
        class HandShank{
            public String color;

            public HandShank(String color) {
                this.color = color;
            }

            public void control(String content){
                System.out.println(this.color+"的手柄用来控制"+content);
            }
        }

        Mouse mouse = new Mouse("罗技",10);

        mouse.clickContent("打游戏");

        HandShank handShank = new HandShank("white");
        handShank.control("人物的行走路线");

    }

    public void writeProgram(){

        Mouse mouse = new Mouse("雷柏",3);
        mouse.clickContent("写程序");


        KeyBoard keyBoard = new Computer.KeyBoard("罗技",87);
        keyBoard.inputContext("在写程序");

    }
}
